import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
    path: '/',
    name: 'Home',
    component: () => import('@/views/Home')
  },
  {
    name: 'repairReq',
    path: '/repair/repairReq',
    component: () => import('@/views/repair/repairReq'),
    meta: {
      title: '报修申请',
    }
  },
  {
    name: 'reqHistory',
    path: '/repair/reqHistory',
    component: () => import('@/views/repair/reqHistory'),
    meta: {
      title: '维修记录',
    }
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/error/404'),
    meta: {
      title: '404-NotFound'
    }
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }

]


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const router = new VueRouter({
  routes
})

export default router
